package com.chuangjiangx.member.coupon.ddd.domain.model;

import com.chuangjiangx.dddbase.Entity;
import com.chuangjiangx.member.coupon.ddd.domain.model.MbrWxCardId;
import com.chuangjiangx.member.coupon.ddd.domain.model.ShowEquityEnum;
import com.chuangjiangx.member.coupon.ddd.domain.model.SwicthEnum;
import com.chuangjiangx.member.coupon.ddd.domain.model.WxStatusEnum;
import com.chuangjiangx.member.basic.ddd.domain.model.MerchantId;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Date;
import java.util.List;

/**
 * 微信会员卡信息
 *
 * @author wp
 * @date 2018-08-28 17:27
 **/
@Getter
@AllArgsConstructor
public class MbrWxCard extends Entity<MbrWxCardId>{
    /**
     * 商户id
     */
    private MerchantId merchantId;
    /**
     * 展示列表
     */
    private List<ShowEquityEnum> showEquityList;
    /**
     * 操作提示
     */
    private String operationInstruction;
    /**
     * 自定义入口开关
     */
    private SwicthEnum interfaceSwitch;
    /**
     * 入口名称
     */
    private String interfaceName;
    /**
     *  入口引导鱼
     */
    private String interfaceGuide;
    /**
     * 入口链接
     */
    private String interfaceUrl;
    /**
     * 微信卡券id
     */
    private String wxCardId;
    /**
     * 微信审核拒绝原因
     */
    private String wxRefuseReason;
    /**
     * 微信审核状态
     */
    private WxStatusEnum wxStatus;

    private Date wxAuditTime;

    private Date createTime;

    private Date updateTime;

    public MbrWxCard(MerchantId merchantId, List<ShowEquityEnum> showEquityList, String operationInstruction, SwicthEnum interfaceSwitch, String interfaceName, String interfaceGuide, String interfaceUrl) {
        this.merchantId = merchantId;
        this.showEquityList = showEquityList;
        this.operationInstruction = operationInstruction;
        this.interfaceSwitch = interfaceSwitch;
        this.interfaceName = interfaceName;
        this.interfaceGuide = interfaceGuide;
        this.interfaceUrl = interfaceUrl;
        this.createTime = new Date();
    }

    /**
     * 微信审核失败
     * @param wxRefuseReason
     */
    public void auditFail(String wxRefuseReason){
        this.wxStatus = WxStatusEnum.AUDIT_FAIL;
        this.wxRefuseReason = wxRefuseReason;
        this.wxAuditTime = new Date();
        this.updateTime = new Date();
    }

    /**
     * 微信审核成功
     */
    public void auditSuccess(){
        this.wxStatus = WxStatusEnum.AUDIT_SUCCESS;
        this.wxAuditTime = new Date();
        this.updateTime = new Date();
    }

    /**
     * 微信审核中
     */
    public void auditing(String wxCardId){
        this.wxStatus = WxStatusEnum.AUDITING;
        this.wxCardId = wxCardId;
        this.updateTime = new Date();
    }

    public void update(List<ShowEquityEnum> showEquityEnumList,String operationInstruction, SwicthEnum interfaceSwitch, String interfaceName, String interfaceGuide, String interfaceUrl){
        this.showEquityList = showEquityEnumList;
        this.operationInstruction = operationInstruction;
        this.interfaceSwitch = interfaceSwitch;
        this.interfaceName = interfaceName;
        this.interfaceGuide = interfaceGuide;
        this.interfaceUrl = interfaceUrl;
        this.updateTime = new Date();
    }

    //更新审核失败原因
    public void setWxRefuseReason(String wxRefuseReason) {
        this.wxRefuseReason = wxRefuseReason;
    }

    //更新审核状态
    public void setWxStatus(WxStatusEnum wxStatus) {
        this.wxStatus = wxStatus;
    }
}
